<!--Copyright https://gitee.com/laiyw/manage-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="icon" href="statics/images/favicon.ico" type="image/x-icon"/>
    <title>Manage | 登录</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="plugins/AdminLTE/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="plugins/AdminLTE/dist/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="plugins/AdminLTE/dist/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="plugins/AdminLTE/dist/css/AdminLTE.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="plugins/AdminLTE/plugins/iCheck/square/blue.css">
    <!-- toastr -->
    <link rel="stylesheet" href="plugins/toastr/toastr.min.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script>
        if (window.parent.window != window) {
            window.top.location = "login.html";
        }
    </script>
</head>
<body class="hold-transition login-page" style="background-image: url('https://goss1.veer.com/creative/vcg/veer/612/veer-153787711.jpg');
        background-position: center,center; background-size: cover; background-repeat: no-repeat;
        background-attachment: fixed; overflow: hidden">
<div class="login-box">
    <div class="login-logo">
        <span><b>Manage</b></span>
    </div>
    <!-- /.login-logo -->
    <div class="login-box-body">
        <form id="frm" method="post">
            <div class="form-group has-feedback">
                <input id="account" name="account" value="admin" type="text" class="form-control" placeholder="账号/邮箱">
                <span class="glyphicon glyphicon-user form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input id="passwd" name="password" value="123456" type="password" class="form-control" placeholder="密码">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="row">
                <div class="col-xs-8">
                    <div class="checkbox icheck">
                        <label>
                            <input name="rememberMe" type="checkbox" value="true"> 记住我
                        </label>
                    </div>
                </div>
                <div class="col-xs-4">
                    <button onclick="submitForm()" type="button" class="btn btn-primary btn-block btn-flat">登录</button>
                </div>
            </div>
        </form>
        <div class="row" style="margin-top: 10px;">
            <div class="col-xs-6">
                <a href="forgetPwd.html">忘记密码</a><br>
            </div>
        </div>
        <div class="social-auth-links text-center">
            <button data-toggle="modal" data-target="#emailModal"
                    class="btn btn-block btn-social btn-facebook btn-flat">
                <i class="glyphicon glyphicon-envelope"></i>邮箱快速登录
            </button>
        </div>
    </div>
</div>

<div id="emailModal" class="modal fade" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">邮箱验证登录</h4>
            </div>
            <div class="modal-body">
                <form onsubmit="return false" class="form-horizontal">
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-2 control-label">邮箱</label>
                        <div class="col-xs-8">
                            <input type="email" name="email" class="form-control">
                            <span class="help-block ">登录账号所绑定的邮箱！</span>
                        </div>
                        <button onclick="getverificationCode()" class="btn btn-info">获取</button>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-2 control-label">验证码</label>
                        <div class="col-sm-8">
                            <input type="text" name="verificationCode" class="form-control">
                        </div>
                        <button onclick="emailLogin()" type="button" class="btn btn-primary">验证</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- jQuery 2.2.3 -->
<script src="plugins/AdminLTE/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="plugins/AdminLTE/bootstrap/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="plugins/AdminLTE/plugins/iCheck/icheck.min.js"></script>
<!-- toastr -->
<script src="plugins/toastr/toastr.min.js"></script>
<script>
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' // optional
        });

        $("#passwd").keyup(function (event) {
            if (event.keyCode == 13) {
                submitForm();
            }
        });
    });

    function emailLogin() {
        if (!$("input[name='email']").val()) {
            toastr.error("请输入邮箱");
            return false;
        }
        if (!$("input[name='verificationCode']").val()) {
            toastr.error("请输入验证码");
            return false;
        }
        $.ajax({
            type: "post",
            data: {
                mailbox: $("input[name='email']").val(),
                verificationCode: $("input[name='verificationCode']").val()
            },
            url: "/manage/verificationCodeLogin",
            success: function (data) {
                if (data.success) {
                    location.href = "index.html";
                } else {
                    toastr.error(data.message);
                }
            }
        });
    }

    function getverificationCode() {
        if (!$("input[name='email']").val()) {
            toastr.error("请输入邮箱");
            return false;
        }
        $.ajax({
            type: "post",
            data: {
                email: $("input[name='email']").val()
            },
            url: "/common/getVerificationCode",
            success: function (result) {
                if (result.success) {
                    toastr.success(result.message)
                } else {
                    toastr.error(result.message);
                }
            }
        });
    }

    function submitForm() {
        if (!$("#account").val() || !$("#passwd").val()) {
            toastr.error("请输入用户名或密码")
            return false;
        } else {
            $.ajax({
                type: "post",
                data: $("#frm").serialize(),
                url: "/manage/login",
                success: function (data) {
                    if (data.success) {
                        location.href = "index.html";
                    } else {
                        toastr.error(data.message);
                    }
                }
            });
        }
    }
</script>
</body>
</html>
